﻿package  
{
	import com.greensock.*;
	import com.greensock.easing.*;
	
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.AntiAliasType;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	
	
	/**
	 * ...
	 * @author zhengzihua
	 */
	public class MenuMC extends Sprite
	{
		public var menuTxt:TextField;
		private var textFormat:TextFormat;
		public function MenuMC(str:String) 
		{
			menuTxt = new TextField();
			textFormat = new TextFormat("Arial", 14,StaticInfo.MENU_FONT_DEFAULT_COLOR);
			
			menuTxt.textColor = StaticInfo.MENU_FONT_DEFAULT_COLOR;
			menuTxt.text = str;
			menuTxt.autoSize = TextFieldAutoSize.LEFT;
			menuTxt.selectable = false;
			menuTxt.antiAliasType = AntiAliasType.ADVANCED;
			//menuTxt.defaultTextFormat = textFormat;
			menuTxt.setTextFormat(textFormat);
			
			addChild(menuTxt);
			var effArr:Array=new Array();
			effArr.push(StaticInfo.BLUR_EFFECT);
			menuTxt.filters=effArr;
			addEvent();
			
		}
		private function addEvent():void{
			//menuTxt.addEventListener(MouseEvent.CLICK, onClick);
			menuTxt.addEventListener(MouseEvent.ROLL_OVER, onRollover);
			menuTxt.addEventListener(MouseEvent.ROLL_OUT, onRollout);
		}
		private function delEvent():void{
			//menuTxt.removeEventListener(MouseEvent.CLICK, onClick);
			menuTxt.removeEventListener(MouseEvent.ROLL_OVER, onRollover);
			menuTxt.removeEventListener(MouseEvent.ROLL_OUT, onRollout);
		}
		private function onRollout(e:MouseEvent=null):void
		{	
			TweenMax.fromTo(menuTxt, 0.3,{} ,{tint:StaticInfo.MENU_FONT_DEFAULT_COLOR});
		}
		
		private function onRollover(e:MouseEvent=null):void 
		{	
			TweenMax.fromTo(menuTxt, 0.3, {},{tint:StaticInfo.MENU_FONT_ROLLOVER_COLOR});
		}
		public function onClick(e:MouseEvent=null):void 
		{
			//DebugTrace.dtrace("code info MenuMC.as:点击菜单.");
			delEvent();
		}
		public function resume():void{
			onRollout();
			addEvent();
		}
	}
	
}